package types

import (
	"path"

	"github.com/gin-gonic/gin"
)

// Handler http handle inteface
type Handler interface {
	Handle(*gin.Engine)
	Name() string
}

// SomeHandler some handler
type SomeHandler []Handler

// Handle inferface implement
func (hs SomeHandler) Handle(e *gin.Engine) {
	var apis []string
	for _, h := range hs {
		h.Handle(e)
		apis = append(apis, path.Base(h.Name()))
	}
	e.GET("/api", func(c *gin.Context) {
		c.JSON(200, apis)
	})
}
